<?php
/**
 * Page to DoS class
 *
 * @package eesc
 */ 

/**
 * Require rules
 */
require_once BASE_URI . "/inc/config.inc.php";

/**
 * DoS Class
 * 
 * Object created from DoSs userid, then makes available a list
 * of functions to that DoS
 *
 * $Rev:: 48            $:  Revision of last commit
 * $Author:: guy        $:  Author of last commit
 * $Date:: 2010-04-19 1#$:  Date of last commit
 *
 * @package eesc
 * @subpackage classes
 */
class DoS {
	private $userid;

	/**
	 * Constructor
	 * 
	 * @param object $userid 
	 */
	function __construct($userid) {
		
		$this->userid = $userid;
		
		// to be replace by database connection
		// SELECT DoS Name and College
		//include_once '/Users/gc291/Projects/eesc/globals.php';
		
		//$this->name = $DoS_array[$this->userid]['name'];
		
		//$this->college = $DoS_array[$this->userid]['College'];
		
		//$this->part = $DoS_array[$this->id]['Tripos'];
		
		//to be replaced by selecting all students belonging to a DoS
		
		
	}
	
	/**
	 * Retrieve the DoSs title
	 * 
	 * @return string $name
	 */
	function getName() {
		$tis = new TIS();
		$data = $tis->select('tbl_people',array('STR_Initials','STR_Surname'),"WHERE A_INT_PersonID =".$this->userid);

		return $data[0]['STR_Initials'] . " " . $data[0]['STR_Surname'];
	}
	
	
		
	/**
	 * Returns list of the DoSs students
	 * 
	 * @param string $status [optional]
	 * @return array $students an associative array
	 */
	function getStudents($status = NULL) {
		if (!$local) {
			$tis = new TIS();
			$data = $tis->select('qry_currentStudentsAndDoSs',array('USN','Surname'),"WHERE `Dos ID` =".$this->userid);
			$students = array();
			foreach ($data as $row) {
				$students[$row["USN"]] = $row["Surname"];
			}
			
			return $students;
			
		}
		/*return array(300625257 => "Bob" ,300614088 => "Jim" ,300623921 => "Neville");*/
	}
	
	/**
	 * Function to return assoiciative array of students
	 * 
	 * @deprecated
	 * @param object $status [optional]
	 * @return array $students
	 */
	function getAssocStudents($status = NULL) {
		return $this->getStudents();
		//var_dump($this->students);
		//return $this->students;
		//return array(300625257 => "Bob" ,300614088 => "Jim" ,300623921 => "Neville");
	}

}
